lpad
lpad
Description
Syntax:
VARCHAR lpad (VARCHAR str, INT len, VARCHAR pad)
This function returns a string of length len in str, starting from the first letter of the string. If len is longer than str, it will put the characters of pad to the start of str until the specified length is reached. If len is shorter than str, it will truncate the str string and return a string of the specified length. len is about character length but not bye size.
Example
mysql> SELECT lpad("hi", 5, "xy");
+---------------------+
| lpad('hi', 5, 'xy') |
+---------------------+
| xyxhi |
+---------------------+
mysql> SELECT lpad("hi", 1, "xy");
+---------------------+
| lpad('hi', 1, 'xy') |
+---------------------+
| h |
+---------------------+
Keywords
LPAD